<?php

class HmNews_HmTagsController extends Fw_Main
{
	public function listAction()
	{
		$_model = $this->_getModel('HmNewsTagsDescr');
		$list_tags = $_model->getAll();
		$this->view->list_tags = $list_tags;
		$this->view->rowcount = count($list_tags);
	}
	
	public function addAction()
	{
		$this->validateUser();
		if($this->_request->isPost()){
			$formData = $this->_request->getPost('add');
			if($formData) {
				$data = array('description' => $this->_request->getPost('description'));
				$_model = $this->_getModel('HmNewsTagsDescr');
				$add_row = $_model->addRow($data);
				return $this->_helper->redirector('list');
			}
		}
	}
	
	public function deleteAction()
	{
		$this->validateUser();
		$id = (int)$this->_request->getParam('tags_id');
		$_model = $this->_getModel('HmNewsTagsDescr');
		$delete_link = $_model->deleteRow($id);
		return $this->_helper->redirector('list');
	}
}